import { get, postJson as post } from "@/utils/http.request"
import { baseRes } from '@/interfaces/api.interface'
import urlFunc from "@/utils/url.func"

type fn =  typeof get | typeof post
const BASE = (fn: fn) => {
	return function<T = obj>(url: string) {
		return function (params?: obj) {
			return fn<baseRes<T>>({
				url: urlFunc.requestHost("api") + 'api/' + url,
				params
			}).then(res => res.data)
		} 
	} 
}

const GET = BASE(get)
const POST = BASE(post)

export const register = POST<string>('account/register')

export const login = POST<string>('account/login')

export const sendCode = GET('account/sendVerificationCode')

export const getKey = POST<string>('account/getSecretKey')

export const forget = POST('account/retrievePassword')

export const getUser = GET('account/getUserInfo')

export const getDefault = GET<string>('exhibition/default')

export const getSolus = GET<obj[]>('solution/list')

export const getSolu = GET<obj[]>('solution/find')

export const getPro = GET('product/findById')

export const getMenu = GET<obj[]>('exhibition/menubar/listMenubar')

export const getBanner = GET<obj[]>('exhibition/banner/listBannerByExhibitionId')

export const getProcess = GET<obj[]>('exhibition/process/listProcessByExhibitionId')

export const getInfo = GET('exhibition/info')

export const getVideo = GET('exhibition/video/list')

export const getImg = GET('exhibition/image/list')

export const getNew = GET('exhibition/news/list')

export const getPartner = GET<obj[]>('exhibition/media/listMediaByExhibitionId')

export const gethall = GET<obj[]>('exhibition/industry/listIndustryByExhibitionId')

// export default {
// 	envConfig() {
// 		return get<obj>({
// 			url: `${urlFunc.requestHost("api")}/envConfig`
// 		})
// 	},
// 	demo: GET('demo')
// }
